package com.example.wjh.mapper;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.wjh.entity.Coach;
import org.apache.ibatis.annotations.*;


/**
 * 篮球教练
 *
 * @author
 * @email
 * @date 2022-07-31 07:01:29
 */
@Mapper
public interface CoachMapper extends BaseMapper<Coach> {
    @Select("SELECT * FROM coach WHERE username = #{username} AND password = #{password}")
    Coach login(@Param("username") String username, @Param("password") String password);

    @Mapper
        @Select("<script> " +
                "SELECT * FROM coach " +
                "<where> " +
                "<if test='name != null'> AND name LIKE CONCAT('%', #{name}, '%')</if> " +
                "<if test='username != null'> AND username LIKE CONCAT('%', #{username}, '%')</if> " +
                "<if test='teachage != null'> AND CAST(teachage AS UNSIGNED) &gt;= #{teachage}</if> " +
                "<if test='type != null'> AND type LIKE CONCAT('%', #{type}, '%')</if> " +
                "</where> " +
                "</script>")
        List<Coach> searchCoach(
                @Param("name") String name,
                @Param("username") String username,
                @Param("teachage") String teachage,
                @Param("type") String type);

    @Select("select count(*) from coach where type='进攻为主' ")
    int findmaingong();
    @Select("select count(*) from coach where type='防守为主' ")
    int findmainfang();
    @Select("select count(*) from coach where type='攻防平衡' ")
    int findgongfang();


}
